<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('设备人员列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>姓名：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <span th:text="${message}"></span>
                <a class="btn btn-success" onclick="login()" shiro:hasPermission="conference:member:add">
                    <i class="fa fa-plus"></i> 登录设备
                </a>
                <a class="btn btn-success" onclick="syncAll()" shiro:hasPermission="conference:member:add">
                    <i class="fa fa-plus"></i> 同步人员信息
                </a>
                <a class="btn btn-success" onclick="config()" shiro:hasPermission="conference:member:add">
                    <i class="fa fa-plus"></i> 更新接口地址
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('conference:member:edit')}]];
        var removeFlag = [[${@permission.hasPermi('conference:member:remove')}]];
        var statusDatas = [[${@dict.getType('yz_member_status')}]];
        var prefix = ctx + "conference/device";

        $(function() {
            var options = {
                url: prefix + "/list",
                updateUrl: prefix + "/sync",
                removeUrl: prefix + "/remove",
                configUrl: prefix + "/config",
                loginUrl: prefix + "/login",
                modalName: "参会人员",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'person_name',
                    title: '姓名'
                },
                {
                    field: 'phone_num',
                    title: '手机号码'
                },
                {
                    field: 'check_feature_status',
                    title: '入库状态'
                },
                {
                    field: 'check_feature_status',
                    title: '入库状态说明',
                    formatter: function(value, row, index) {
                        return codeMsg(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="sync(\'' + row.id + '\')"><i class="fa fa-edit"></i>重新同步</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function login() {
            $.modal.confirm("确定登录设备吗？", function() {
                let url = table.options.loginUrl;
                $.operate.submit(url, "post", "json", null);
            });
        }

        function sync(id) {
            $.modal.confirm("确定同步该条" + table.options.modalName + "信息吗？", function() {
                let url = table.options.updateUrl + "/" + id;
                $.operate.submit(url, "put", "json", null);
            });
        }

        function syncAll() {
            $.modal.confirm("确定同步所有人员信息吗？", function() {
                let url = table.options.updateUrl + "All";
                $.operate.submit(url, "post", "json", null);
            });
        }

        function config() {
            $.modal.confirm("确定更新接口地址吗？", function() {
                let url = table.options.configUrl;
                $.operate.submit(url, "post", "json", null);
            });
        }

        function codeMsg(data) {
            if (data == null) {
                return "";
            }
            let codeMap = new Map();
            codeMap.set(0,"未下发");
            codeMap.set(1,"入库中");
            codeMap.set(2,"特征值已入库");
            codeMap.set(3,"下载失败");
            codeMap.set(4,"feature长度校验失败");
            codeMap.set(16,"格式错误");
            codeMap.set(17,"尺寸过大");
            codeMap.set(18,"尺寸过小");
            codeMap.set(19,"分辨率超限");
            codeMap.set(32,"未抽取到特征");
            codeMap.set(33,"无图片");
            codeMap.set(34,"未检测到人脸");
            codeMap.set(35,"检测到多人脸");
            codeMap.set(36,"人脸过小");
            codeMap.set(37,"图片过亮");
            codeMap.set(38,"图片过暗");
            codeMap.set(39,"图片模糊");
            codeMap.set(40,"人脸角度过大");
            codeMap.set(41,"图片重复");
            codeMap.set(42,"人脸重复");
            codeMap.set(43,"人脸佩戴口罩");
            codeMap.set(255,"未知");

            if (codeMap.has(data)) {
                return codeMap.get(data);
            }

            return "";
        }
    </script>
</body>
</html>
